package com.cn.indentManage.entity;

import java.util.List;

public class Page<T> {
	private int currentPage=1; //当前页码
	private int pageSize=10; //一页数据的条数
	private int begin; //开始的序号
	private int end; //结束的序号
	private int rows;  //一共的行数
	private int totalPage; //总页数
	private int sort;//排序
	private String search;//关键字
	private List<T>list;

	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}
	public String getSearch() {
		return search;
	}
	public Page setSearch(String search) {
		this.search = search;
		return this;
	}
	public int getSort() {
		return sort;
	}
	public Page setSort(int sort) {
		this.sort = sort;
		return this;
	}
	public int getBegin() {
		begin = (currentPage - 1) * pageSize;
		return begin;
	}
	public int getEnd() {
		end = currentPage * pageSize + 1;
		return end;
	}
	public int getTotalPage() {
		if (rows % pageSize == 0) {
			totalPage = rows / pageSize;
		} else {
			totalPage = rows / pageSize + 1;
		}
		return totalPage;
	}
	public int getCurrentPage() {
		return currentPage;
	}

	public Page setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
		return this;
	}

	public int getPageSize() {
		return pageSize;
	}

	public Page setPageSize(int pageSize) {
		this.pageSize = pageSize;
		return this;
	}

	public int getRows() {
		return rows;
	}

	public Page setRows(int rows) {
		this.rows = rows;
		if (currentPage > getTotalPage()) {
			currentPage = getTotalPage();
		}
		return this;
	}
	@Override
	public String toString() {
		return "Page [currentPage=" + currentPage + ", pageSize=" + pageSize + ", begin=" + begin + ", end=" + end
				+ ", rows=" + rows + ", totalPage=" + totalPage + ", sort=" + sort + ", search=" + search + ", list="
				+ list + "]";
	}


}
